<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // es6 的面相对象 class 类名{ constructor(){} 方法名(){}}
        // extends 和 super 同时出现才是继承 
        class Person{
            constructor(name,age){
                this.name = name;
                this.age = age;
            }
            sayHello(){
                console.log('我是原型继承');
            }
        }

        class Student extends Person{
            constructor(gender,...args){
                
                super(...args); //继承父类的构造函数 
                // super 写在子类的构造函数中，只能写在第一行
                this.gender = gender;
            }
        }

        const s1 = new Student('男','张三',18);
        console.log(s1);

        console.log(s1.name);
        console.log(s1.age);
        s1.sayHello()

</script>
</body>
</html>